package org.csu.jpetmanage.service.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.csu.jpetmanage.mapper.SupplierMapper;
import org.csu.jpetmanage.model.Supplier;
import org.csu.jpetmanage.service.SupplierService;
import org.springframework.stereotype.Service;

@Service
public class SupplierServiceImpl extends ServiceImpl<SupplierMapper, Supplier> implements SupplierService {

    @Override
    public Page<Supplier> list(Supplier supplier, long current, long size) {
        QueryWrapper<Supplier> queryWrapper = new QueryWrapper<>();
        if (null != supplier.getSuppid()){
            queryWrapper.eq("suppid", supplier.getSuppid());
            queryWrapper.like("productid", supplier.getName());
            queryWrapper.like("status", supplier.getStatus());
            queryWrapper.like("addr1", supplier.getAddr1());
            queryWrapper.like("addr2", supplier.getAddr2());
            queryWrapper.like("city", supplier.getCity());
            queryWrapper.like("state", supplier.getState());
            queryWrapper.like("zip", supplier.getZip());
        }

        return baseMapper.selectPage(new Page<>(current, size), queryWrapper);
    }
}
